package com.heima.book_system;

import java.util.ArrayList;

public class BookStore implements OnlineBookStore {
    private ArrayList<Book> list;

    public BookStore(ArrayList<Book> list) {
        this.list = list;
    }

    @Override
    public void addBook(Book book) {
        list.add(book);
    }

    @Override
    public void displayBooks() {
        for (int i = 0; i < list.size(); i++) {
            Book b = list.get(i);
            b.displayInfo();
        }

    }

    @Override
    public void calculateTotalPrice() {
        double totalPrice = 0;
        for (int i = 0; i < list.size(); i++) {
            Book b = list.get(i);
           totalPrice += b.getPrice();
        }
        System.out.println("图书总价格为:" + totalPrice);
    }
}
